package com.doodle.sharedpreferences;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * Created by ZZW on 2016/3/20.
 */
public class DBHelper extends SQLiteOpenHelper {

    public DBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context,name,factory,version);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql="create table users (id integer primary key autoincrement,name text,age integer)";
        db.execSQL(sql);
        Log.i("zzw","数据库创建了。。。。。。。。。。。");
    }

    /*该方法的调用时间是：当数据库结构改变，版本version改变时*/
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        String sql="create table users (id integer primary key autoincrement,name text,age integer)";
        db.execSQL(sql);
        Log.i("zzw","upgrade被调用了.........................");
    }
}
